/**
 * Created by Administrator on 2017/1/3.
 */
var async = require('async');
router.get('/detail/:_id', function (req, res) {
    async.parallel([function(callback){
        Model('Article').findOne({_id:req.params._id}).populate('user').populate('comments.user').exec(function(err,article){
            article.content = markdown.toHTML(article.content);
            callback(err,article);
        });
    },function(callback){
        Model('Article').update({_id:req.params._id},{$inc:{pv:1}},callback);
    }],function(err,result){
        if(err){
            req.flash('error',err);
            res.redirect('back');
        }
        res.render('article/detail',{title:'查看文章',article:result[0]});
    });
});